/**
 * Created by fengquan on 2016/11/16.
 */

var express=require("express");
var app=express();//执行express里的全局函数，返回一个express对象

app.configure(function(){

    app.use(express.bodyParser());//设置post请求模块，专门处理post请求
    app.use(express.methodOverride());//设置协助post请求模块，将非get请求转换为其他请求
    app.use(app.router);//配置路由，必须在静态资源前面，配置路由后，先执行用户定义的拦截
    app.use(express.static(__dirname+"/public"));//设置静态资源路径
    app.use(express.errorHandler());//开发者模式，将错误显示在页面上

});

app.post("/test.do",function(req,res){
    var nameOne=  req.body.name1;
    var nameTwo= req.body.name2;
    res.send('1');

});

app.get('/test2.do', function (req,res) {
    var a1=req.query.a1;
    var a2=req.query.a2;
    var a3=req.query.a3;
    
});



var tiyanSecond=[
{id:1,imgSrc:"../img/tiyanSecondImg/pic1.jpg",details:"水岸边，阡陌尽头，盼你缓缓归。",initiator:"路帅",
location:"成都",time:"2016年1月14日",jioner:"5名"},
{id:2,imgSrc:"../img/tiyanSecondImg/pic2.jpg",details:"水岸边，阡陌尽头，盼你缓缓归。",initiator:"路帅",
location:"成都",time:"2016年2月14日",jioner:"5名"},
{id:3,imgSrc:"../img/tiyanSecondImg/pic3.jpg",details:"水岸边，阡陌尽头，盼你缓缓归。",initiator:"路帅",
location:"成都",time:"2016年3月14日",jioner:"5名"},
{id:4,imgSrc:"../img/tiyanSecondImg/pic4.jpg",details:"水岸边，阡陌尽头，盼你缓缓归。",initiator:"路帅",
location:"成都",time:"2016年4月14日",jioner:"5名"},
{id:5,imgSrc:"../img/tiyanSecondImg/pic5.jpg",details:"水岸边，阡陌尽头，盼你缓缓归。",initiator:"路帅",
location:"成都",time:"2016年5月14日",jioner:"5名"},
{id:6,imgSrc:"../img/tiyanSecondImg/pic6.jpg",details:"水岸边，阡陌尽头，盼你缓缓归。",initiator:"路帅",
location:"成都",time:"2016年6月14日",jioner:"5名"}
];


					/*这是体验二级页面建的模拟数据库开始，莫乱抢！*/
					
					
app.post("/tiyanSecondGet.do",function(req,res){
	res.send(tiyanSecond);
});
app.post("/toThird.do",function(req,res){
	var id=req.body.id;
	for(var i=0;i<tiyanSecond.length;i++){
		if(id==tiyanSecond[i].id){
			res.send(tiyanSecond[i]);
		}
	}
});



/***********************************生活方式开始************************************/
var lifeStyleOne=[{lifeImgId:1,lifeImgSrc:"img/lifeStyleImg/tu08.jpg",lifeTxt:"特辑",lifeNumber:24},
{lifeImgId:2,lifeImgSrc:"img/lifeStyleImg/tu05.jpg",lifeTxt:"少数人",lifeNumber:1},
{lifeImgId:3,lifeImgSrc:"img/lifeStyleImg/tu04.jpg",lifeTxt:"言语",lifeNumber:17},
{lifeImgId:4,lifeImgSrc:"img/lifeStyleImg/tu07.jpg",lifeTxt:"印象",lifeNumber:24}
];

//生活方式详情页
var lifeStyleTeJi=[
{lifeImgId:1,lifeTejiTitle:"特辑", lifeTeJiImgSrc:"img/lifeStyleImg/tu01.jpg",lifeTeJiTxt:"你想过体验一下别人的生活吗？",llifeTeJiTime:"2016.11.20"},
{lifeImgId:1,lifeTejiTitle:"特辑",lifeTeJiImgSrc:"img/lifeStyleImg/tu03.jpg",lifeTeJiTxt:"待着生活艺术节",llifeTeJiTime:"2016.11.21"},
{lifeImgId:1,lifeTejiTitle:"特辑",lifeTeJiImgSrc:"img/lifeStyleImg/tu05.jpg",lifeTeJiTxt:"北京待法二锦囊",llifeTeJiTime:"2016.11.22"},
{lifeImgId:1,lifeTejiTitle:"特辑",lifeTeJiImgSrc:"img/lifeStyleImg/tu06.jpg",lifeTeJiTxt:"老北京胡同微旅行",llifeTeJiTime:"2016.11.22"},
{lifeImgId:1,lifeTejiTitle:"特辑",lifeTeJiImgSrc:"img/lifeStyleImg/tu09.jpg",lifeTeJiTxt:"你想过体验一下别人的生活吗？",llifeTeJiTime:"2016.11.28"},
{lifeImgId:1,lifeTejiTitle:"特辑",lifeTeJiImgSrc:"img/lifeStyleImg/tu16.jpg",lifeTeJiTxt:"你想过体验一下别人的生活吗？",llifeTeJiTime:"2016.11.29"},
{lifeImgId:2,lifeTejiTitle:"少数人",lifeTeJiImgSrc:"img/lifeStyleImg/tu12.jpeg",lifeTeJiTxt:"骨灰级待萌，杭州金牌线人",llifeTeJiTime:"2016.11.30"},
{lifeImgId:3,lifeTejiTitle:"言语",lifeTeJiImgSrc:"img/lifeStyleImg/tu09.jpg",lifeTeJiTxt:"冬日青山和恒在，蘼芜几许",llifeTeJiTime:"2016.12.1"},
{lifeImgId:3,lifeTejiTitle:"言语",lifeTeJiImgSrc:"img/lifeStyleImg/tu21.jpeg",lifeTeJiTxt:"2016的最后一个月，你想做件什么小事",llifeTeJiTime:"2016.12.2"},
{lifeImgId:3,lifeTejiTitle:"言语",lifeTeJiImgSrc:"img/lifeStyleImg/tu03.jpg",lifeTeJiTxt:"你想过体验一下别人的生活吗？",llifeTeJiTime:"2016.12.2"},
{lifeImgId:4,lifeTejiTitle:"印象",lifeTeJiImgSrc:"img/lifeStyleImg/tu07.jpg",lifeTeJiTxt:"你想过体验一下别人的生活吗？",llifeTeJiTime:"2016.12.3"},
{lifeImgId:4,lifeTejiTitle:"印象",lifeTeJiImgSrc:"img/lifeStyleImg/tu05.jpg",lifeTeJiTxt:"最难驱散的是心霾",llifeTeJiTime:"2016.12.3"}
];
//请求生活方式页面信息
app.post("/lifeStyleOne.do",function (req,res){
    res.send(lifeStyleOne);
//  console.log(lifeStyleOne);
});
//请求生活方式页面详细信息

app.post("/subLifeStyleOne.do",function (req,res){
	var arrLife=[];
	var productId=req.body.proId;
	for(var i=0;i<lifeStyleTeJi.length;i++){

		if(productId==lifeStyleTeJi[i].lifeImgId){
			arrLife.push(lifeStyleTeJi[i]);
		}
	}
	res.send(arrLife);
});

/***********************************生活方式结束************************************/


/***********************************美文开始**********************************/
var huati=[
	    {imgid:1,huatiname:"待着想想下一秒和前一秒", imgsrc:"img/huatiImg/t1.png"},
	    {imgid:2,huatiname:"唯美摄影", imgsrc:"img/huatiImg/t2.png"},
	    {imgid:3,huatiname:"你对心理学有什么看法……", imgsrc:"img/huatiImg/t3.png"},
	    {imgid:4,huatiname:"与自己的相遇", imgsrc:"img/huatiImg/t4.png"},
	    {imgid:5,huatiname:"白日梦", imgsrc:"img/huatiImg/t5.png"},
	    {imgid:6,huatiname:"幸运的种子", imgsrc:"img/huatiImg/t6.png"},
	    {imgid:7,huatiname:"是什么让你驻足这款APP", imgsrc:"img/huatiImg/t7.png"},
	    {imgid:8,huatiname:"每天都有勇气，对自己说早安！", imgsrc:"img/huatiImg/t8.png"},
	    {imgid:9,huatiname:"人和人的沟通，有时候没有用。", imgsrc:"img/huatiImg/t9.png"},
	    {imgid:10,huatiname:"我还是很喜欢你", imgsrc:"img/huatiImg/t10.png"},
	    {imgid:11,huatiname:"看不到远方，就做一头蛮牛。", imgsrc:"img/huatiImg/t11.png"},
	    {imgid:12,huatiname:"遇朋友、有理想。", imgsrc:"img/huatiImg/t12.png"},
	    {imgid:13,huatiname:"一人一句 用自己的专业表白", imgsrc:"img/huatiImg/t13.png"},
	    {imgid:14,huatiname:"你身边的朋友真的有够义气吗。", imgsrc:"img/huatiImg/t14.png"},
	    {imgid:15,huatiname:"晒一晒你认为的高逼格皮具", imgsrc:"img/huatiImg/t15.png"},
	    {imgid:16,huatiname:"9月一个人去杭州玩，去哪里呢？", imgsrc:"img/huatiImg/t16.png"},
	    {imgid:17,huatiname:"面对物欲，如何面对？", imgsrc:"img/huatiImg/t17.png"},
	    {imgid:18,huatiname:"肥猫画舍的零基础油画体验！", imgsrc:"img/huatiImg/t18.png"},
	    {imgid:19,huatiname:"一群人争先恐后爬山", imgsrc:"img/huatiImg/t19.png"},
	    {imgid:20,huatiname:"艺术复活乡村丨原乡乌 托邦", imgsrc:"img/huatiImg/t20.png"},
	    {imgid:21,huatiname:"安静轻松 随意的生活", imgsrc:"img/huatiImg/t21.png"},
	    {imgid:22,huatiname:"关于暗恋过的人", imgsrc:"img/huatiImg/t22.png"}
	
	 
	];
app.post("/huati.do",function(request,response){
	response.send(huati);
});

app.post("/huatiSecond.do",function(request,response){
	var id=request.body.id;
	for(var i=0;i<huati.length;i++){
		if(id==huati[i].imgid){
			response.send(huati[i]);
		}
	}
	
});
/***********************************美文************************************/


app.set("port",8022);

app.listen(app.get("port"),function(){
    console.log("请求成功");
});


/*-----------------------------------登录-----------------------*/
var loginCheck=[
	{userName:"冯兆海",pwd:"123456"},
	{userName:"王磊",pwd:"654321"},
	{userName:"梁红兵",pwd:"456789"},
	{userName:"张静",pwd:"987654"},
	{userName:"雷奥",pwd:"123789"}

];

/*判断用户名存在*/
app.post("/login.do",function (req,res){
var name=req.body.userName;
	for(var i=0;i<loginCheck.length;i++){
		if(loginCheck[i].userName!=name){
			res.send("0");/*用户名不存在*/
		}else{
			res.send("1");
		}
	}
    
});

/*登录*/
app.post("/denglu.do",function (req,res){

		for(var i=0;i<loginCheck.length;i++){

			if(req.body.userName==loginCheck[i].userName&&req.body.pwd==loginCheck[i].pwd){
				res.send('1');/*登录成功*/
			}else{
				res.send('0');
			}

		}



});

/*-----------------------------------待着-----------------------*/

var tiYanData=[
	{tiYanId:1,tiYanStyle:"好物",tiYanDes:"待着.喝茶--平凡生活中的仪式感",tiTanName:"原创设计",tiYanImgSrc:"img/tiyanImg/travel12.jpg"},
	{tiYanId:2,tiYanStyle:"偷闲",tiYanDes:"我有一瓶酒换你乘风的记忆",tiTanName:"中国",tiYanImgSrc:"img/tiyanImg/travel13.jpg"},
	{tiYanId:3,tiYanStyle:"好物",tiYanDes:"优美的高于艺术生活--艺术节纪念T桖&帆布袋",tiTanName:"原创设计",tiYanImgSrc:"img/tiyanImg/travel14.jpg"},
	{tiYanId:4,tiYanStyle:"偷闲",tiYanDes:"【私人定制表情】JESS的好朋友",tiTanName:"原创设计",tiYanImgSrc:"img/tiyanImg/travel15.jpg"},
	{tiYanId:5,tiYanStyle:"慢旅",tiYanDes:"记录好时光--只想为你拍张照片",tiTanName:"杭州",tiYanImgSrc:"img/tiyanImg/travel16.jpg"},
	{tiYanId:6,tiYanStyle:"偷闲",tiYanDes:"离开繁华都市--安静做一天木匠",tiTanName:"背景",tiYanImgSrc:"img/tiyanImg/travel17.jpg"},
	{tiYanId:7,tiYanStyle:"慢旅",tiYanDes:"离市区不远，靠山市很近--龙井山庄的自然之约",tiTanName:"黄州",tiYanImgSrc:"img/tiyanImg/travel18.jpg"},
	{tiYanId:8,tiYanStyle:"慢旅",tiYanDes:"体验绝美的太湖山水生活--太湖花床度假名宿",tiTanName:"苏州",tiYanImgSrc:"img/tiyanImg/travel19.jpg"},
	{tiYanId:9,tiYanStyle:"偷闲",tiYanDes:"和田书房--日店员|第四期",tiTanName:"广州",tiYanImgSrc:"img/tiyanImg/travel20.jpg"}
];

var duJiaData=[
	{duJiaId:1,duJiaStyle:"好物",duJiaDes:"优美的高于生活--艺术节纪念T桖&帆布袋",duJiaName:"北京",duJiaImgSrc:"img/tiyanImg/travel2.jpg"},
	{duJiaId:2,duJiaStyle:"偷闲",duJiaDes:"我有一瓶酒换你乘风的记忆",duJiaName:"中国",duJiaImgSrc:"img/tiyanImg/travel13.jpg"},
	{duJiaId:3,duJiaStyle:"好物",duJiaDes:"优美的高于艺术生活--艺术节纪念T桖&帆布袋",duJiaName:"原创设计",duJiaImgSrc:"img/tiyanImg/travel4.jpg"},
	{duJiaId:4,duJiaStyle:"偷闲",duJiaDes:"【私人定制表情】JESS的好朋友",duJiaName:"原创设计",duJiaImgSrc:"img/tiyanImg/travel5.jpg"},
	{duJiaId:5,duJiaStyle:"慢旅",duJiaDes:"记录好时光--只想为你拍张照片",duJiaName:"杭州",duJiaImgSrc:"img/tiyanImg/travel6.jpg"},
	{duJiaId:6,duJiaStyle:"偷闲",duJiaDes:"离开繁华都市--安静做一天木匠",duJiaName:"背景",duJiaImgSrc:"img/tiyanImg/travel7.jpg"},
	{duJiaId:7,duJiaStyle:"慢旅",duJiaDes:"离市区不远，靠山市很近--龙井山庄的自然之约",duJiaName:"黄州",duJiaImgSrc:"img/tiyanImg/travel8.jpg"},
	{duJiaId:8,duJiaStyle:"慢旅",duJiaDes:"体验绝美的太湖山水生活--太湖花床度假名宿",duJiaName:"苏州",duJiaImgSrc:"img/tiyanImg/travel19.jpg"},
	{duJiaId:9,duJiaStyle:"偷闲",duJiaDes:"和田书房--日店员|第四期",duJiaName:"广州",duJiaImgSrc:"img/tiyanImg/travel10.jpg"},
	{duJiaId:10,duJiaStyle:"偷闲",duJiaDes:"和田书房--日店员|第四期",duJiaName:"广州",duJiaImgSrc:"img/tiyanImg/travel11.jpg"}
];

app.post("/tiYan.do",function(req,res){

	res.send(tiYanData);
});
app.post("/dujia.do",function(req,res){
	res.send(duJiaData);
});
